import { type ActionType, type StoreType } from "./type";
import { createContext } from "react";

export const context = createContext<{
  dispatch: React.Dispatch<ActionType>;
  state: StoreType;
}>({
  dispatch: () => {},
  state: {
    hasUpdate: false
  }
});
export function useStore() {
  const c = useContext(context);
  if (c === undefined) {
    throw new Error("useStore must be used within a StoreProvider");
  }
  return c;
}
